-- CommanderSummon
-- Created by huanghr Apr/15/2016
-- 查看看指挥官召唤兽建筑

-- 初始化
function initCommanderSummon(self)
    self.item:removeAllChildren();
    local class = self.gridData.class;
    local buildingInfo = BuildingBonusM.queryBuildingView(class);
    local petId = self.gridData.pet_id;

    if not buildingInfo then
        error("获取不到建筑查看配置，元素类型：" .. class);
        return;
    end

    local iconPath = getHeroIconPath(petId);

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 已经失效，不处理
                return;
            end

            self:openBuildingView(nil, nil, nil, nil, nil, iconPath);
        end
    end

    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);
    self.item:setPositionX(5);
    self.item:setPositionY(5);
    self.icon:setScale(1.2);

    -- 模型呼吸
    self:doModelBreath(self.icon);
end